using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>

    public class TVC_CATE1Info
    {
        #region Local Variable
        public class Field
        {
            public const string maingroup = "maingroup",
                subtype = "subtype",
                typevalue = "typevalue",
                typename = "typename";
        }
        private String _db;
        private String _maingroup;
        private String _subtype;
        private String _typevalue;
        private String _typename;

        public String db { get { return _db; } set { _db = value; } }
        public String maingroup { get { return _maingroup; } set { _maingroup = value; } }
        public String subtype { get { return _subtype; } set { _subtype = value; } }
        public String typevalue { get { return _typevalue; } set { _typevalue = value; } }
        public String typename { get { return _typename; } set { _typename = value; } }

        #endregion LocalVariable

        #region Constructor
        public TVC_CATE1Info()
        {
            _db = "";
            _maingroup = "";
            _subtype = "";
            _typevalue = "";
            _typename = "";
        }
        public TVC_CATE1Info(
        String maingroup,
        String subtype,
        String typevalue,
        String typename
        )
        {
            _maingroup = maingroup;
            _subtype = subtype;
            _typevalue = typevalue;
            _typename = typename;
        }
        public TVC_CATE1Info(DataRow dr)
        {
            if (dr != null)
            {
                _maingroup = dr[Field.maingroup.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.maingroup.ToString()]);
                _subtype = dr[Field.subtype.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.subtype.ToString()]);
                _typevalue = dr[Field.typevalue.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.typevalue.ToString()]);
                _typename = dr[Field.typename.ToString()] == DBNull.Value ? "" : Convert.ToString(dr[Field.typename.ToString()]);
            }
        }
        public TVC_CATE1Info(DataRowView dr)
            : this(dr.Row)
        {
        }
        public TVC_CATE1Info(TVC_CATE1Info objEntr)
        {
            _maingroup = objEntr.maingroup;
            _subtype = objEntr.subtype;
            _typevalue = objEntr.typevalue;
            _typename = objEntr.typename;
        }
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("TVC_CATE1PRV");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.maingroup.ToString(), typeof(String)),
				new DataColumn(Field.subtype.ToString(), typeof(String)),
				new DataColumn(Field.typevalue.ToString(), typeof(String)),
				new DataColumn(Field.typename.ToString(), typeof(String))
			});
            return dt;
        }
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.maingroup.ToString()] = _maingroup;
            row[Field.subtype.ToString()] = _subtype;
            row[Field.typevalue.ToString()] = _typevalue;
            row[Field.typename.ToString()] = _typename;
            return row;
        }
        #endregion InitTable
    }
}
